#ifndef JOINSESSION_H
#define JOINSESSION_H

#include <QDialog>
#include <QColor>
#include <QListWidget>
#include "ColourButton/colourbutton.h"
#include "Bonjour/bonjourbrowser.h"
#include "Bonjour/bonjourresolver.h"

namespace Ui
{
	class JoinSession;
}

class JoinSession : public QDialog
{
	Q_OBJECT

public:
	JoinSession(QWidget *parent = 0);
	~JoinSession();
	QPair<QString, quint16> getSelectedConnectionData() const {return connectionData;}
	QString getUserName();
	QColor getUserColour();

public slots:
	void accept();

private slots:
	void updateServiceList(QList<BonjourService> newList);	//recieve an updated service list from the bonjourBrowser
	void getResolveInfoAndAccept(QString host, quint16 port);
	void handleBonjourBrowserError();
	void handleBonjourResolveError();

protected:
	void changeEvent(QEvent *e);

private:
	Ui::JoinSession *ui;
	ColourButton *pushButton_textColour;

	BonjourBrowser *browser;
	BonjourResolver *resolver;
	QList<BonjourService> serviceList;	//stores a list of bonjour-services
	QPair<QString, quint16>  connectionData;	//stores the connection data
};

#endif // JOINSESSION_H
